package com.dailyblue.smbms.controller;

import com.alibaba.fastjson2.JSONArray;
import com.dailyblue.smbms.bean.Role;
import com.dailyblue.smbms.service.RoleService;
import com.dailyblue.smbms.service.impl.RoleServiceImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet("/role_find")
public class RoleFindController extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        RoleService service = new RoleServiceImpl();
        List<Role> list = service.find();
        response.setContentType("application/json;charset=utf-8");
        PrintWriter out = response.getWriter();
        String json = JSONArray.toJSONString(list);
        out.println(json);
    }
}